package com.cw.subject.infra.basic.service.impl;

import com.alibaba.fastjson.JSON;
import com.cw.subject.infra.basic.entity.SubjectCategoryPO;
import com.cw.subject.infra.basic.mapper.SubjectCategoryPODao;
import com.cw.subject.infra.basic.service.SubjectCategoryPOService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;
import java.util.List;

/**
 * 题目分类(SubjectCategoryPO)表服务实现类
 *
 * @author makejava
 * @since 2024-03-31 16:10:58
 */
@Service("subjectCategoryService")
@Slf4j
public class SubjectCategoryPOServiceImpl implements SubjectCategoryPOService {
    @Resource
    private SubjectCategoryPODao subjectCategoryPODao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SubjectCategoryPO queryById(Integer id) {
        return this.subjectCategoryPODao.queryById(id);
    }

    /**
     * 新增数据
     *
     * @param subjectCategoryPO 实例对象
     */
    @Override
    public int insert(SubjectCategoryPO subjectCategoryPO) {
        if (log.isInfoEnabled()) {
            log.info("SubjectCatetoryController.add.po:{}", JSON.toJSONString(subjectCategoryPO));
        }
        return this.subjectCategoryPODao.insert(subjectCategoryPO);
    }

    /**
     * 修改数据
     *
     * @param subjectCategoryPO 实例对象
     */
    @Override
    public int update(SubjectCategoryPO subjectCategoryPO) {
        return this.subjectCategoryPODao.update(subjectCategoryPO);
    }

    @Override
    public List<SubjectCategoryPO> queryCategory(SubjectCategoryPO subjectCategoryPO) {
        return this.subjectCategoryPODao.queryCategory(subjectCategoryPO);
    }
}
